<?php
namespace Modules\Order\Entities;

use Modules\Core\Entities\BaseEntity as Model;
use ThrowException;

class DeliverRecord extends Model
{
    protected $guarded = [];
    protected $table = 'deliver_records';

    protected $typeTextMaps = [
        1 => '物流发货',
        2 => '无需物流'
    ];

    protected $typeMaps = [
        1 => 'express',
        2 => 'other'
    ];

    protected $appends = ['type_text'];

    public function getTypeTextAttribute($value)
    {
        return @v($this->typeTextMaps[$value], '未知状态');
    }

    public function getTypeAttribute($value)
    {
        return @v($this->typeMaps[$value], 'unkonw');
    }

    public function setTypeAttribute($value)
    {
        $this->attributes['type'] = array_search($value, $this->typeMaps);
    }
}
